<?php
/**
 * Created by PhpStorm.
 * User: tjjs
 * Date: 17-7-25
 * Time: 下午5:09
 */

namespace ActionsHttp;

use Data\Order_form_DAO;
use Data\Order_for_foods_DAO;
use Data\Food_DAO;
use Data\Retreat_order_form_DAO;

class RestaurantOrderFormListRetreat extends BaseActionHttp
{
    public function doAction() {
        parent::doAction();
        // 每页显示条数
        $every_page_counts = (int)$this->data[EVERY_PAGE_COUNTS];
        // 上一页最后一条订单id
        $last_id = (int)$this->data[LAST_ID];
        // 商铺id
        $restaurant_id = $_SESSION[RESTAURANT_ID];
        $restaurant_id = 1;
        // 日期
        $date = $this->data[DATE];
        // 桌号
        $table_number = $this->data[TABLE_NUM];
        // 订单号
        $order_num = $this->data[ORDER_NUM];

        $retreat_order_status = RETREAT_ORDER_STATUS_START;
        // 退菜申请列表
        $retreat_food_list = Order_form_DAO::getListRetreatOrder($restaurant_id,$date,$retreat_order_status,$last_id,$every_page_counts,$table_number,$order_num);
        $order_info = array();
        foreach ($retreat_food_list as $retreat_food_list_record) {
            $order_form_id = $retreat_food_list_record->getORDER_FORM_ID();
            // 订单中商品信息
            $order_for_food_list = Order_for_foods_DAO::getListByOrderFormId($order_form_id);
            // 订单全部信息
            $order_info_record[ORDER_FORM_INFO] = $retreat_food_list_record->getArray();
            $order_info_record[ORDER_FORM_INFO][ORDER_FOR_FOOD_INFO] = $order_for_food_list;
            $order_info[] = $order_info_record;
        }

        $this->setValue(ORDER_FORM_RETREAT_LIST,$order_info);
        $this->ResponseDataToCurrentClient();
    }
}